import ddddocr
import uvicorn
from fastapi import FastAPI

app = FastAPI(title="ddddocr 测试接口", description="验证码识别测试")

# 初始化 ddddocr
ocr = ddddocr.DdddOcr(show_ad=False)  # show_ad=False 关闭广告提示

@app.get("/test", summary="测试接口连通性")
async def test():
    ocr = ddddocr.DdddOcr()
    with open("example.jpg", 'rb') as f:
        image = f.read()
    res = ocr.classification(image)
    return res



if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8998, reload=True)